import { exists, readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";
/**
 * 资源文件信息接口
 */
export class ResFileInfo{
    /** 文件名 */
    filename?:string;
    /** 文件完整路径 */
    path?:string;
    /**文件内容(文本) */
    content?:string;

    async read():Promise<void>{
        if (this.path){
            this.content = await readTextFile(this.path+'/'+this.filename);
        }
    }
    async write():Promise<void>{
        if (this.path){
            await writeTextFile(this.path+'/'+this.filename,this.content||"");
        }else{
            console.log("ResFileInfo::write():: 路径或内容为空")
        }
    }
    async exists ():Promise<boolean>{
        if (this.path ){
            return await exists(this.path);
        }
        return false;
    }
}